package com.itheima.dao;

import com.itheima.pojo.Staff;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    // 查询所有用户 数据
    @Select("select id,username,gender,idcard,from_address fromAddress,to_address toAddress,start_time startTime from tb_trip")
    List<Staff> queryAll();


    //添加新用户 既数据
    @Insert("insert into tb_trip values (null ,#{username},#{gender},#{idcard},#{fromAddress},#{toAddress},#{startTime})")
    void insertNewUser(Staff staff);



    // 根据ID查询用户的行程数据
    //select * from tb_trip where id = 1
    @Select("select id,username,gender,idcard,from_address fromAddress,to_address toAddress,start_time startTime from tb_trip where id = #{id}")
    Staff queryAllById(Long id);


    // 根据ID修改用户的行程数据
    //update tb_trip set 'username'='zhangsan','gender'=1,'idcard'='xinjiang','from_address'='nanyang',
    //                                              'to_address'='dd','start_time'='data' where id=16;
    @Update("update tb_trip set 'username'=#{username},'gender'=#{gender},'idcard'=#{idcard},'from_address'=#{fromAddress},'to_address'=#{toAddress},'start_time'=#{startTime} where id=#{id}")
    int updateUserById(Staff staff);



    //、根据ID删除用户的行程数据
    //delete  from tb_trip where id = 1
    @Delete("delete  from tb_trip where id = #{id}")
    int deleteUserById(Long id);



}
